/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.view.relations;

import org.jfonia.connect5.basics.BasicValueNode;
import org.jfonia.connect5.basics.MutableValueNode;
import org.jfonia.connect5.basics.ValueNode;
import org.jfonia.connect5.relations.ABCRelation;

/**
 *
 * @author Rik Bauwens
 */
public class IntInversionRelation extends ABCRelation<Integer, Integer, Integer>
{
        public IntInversionRelation(ValueNode<Integer> a, MutableValueNode<Integer> b)
        {
                super(a, new BasicValueNode<Integer>(-1), b);
        }

        @Override
        public void updateC()
        {
                //Value -0.0 causes issues;
                //Only update node C with the inverted value
                //when the value of node A is not 0.0
                if(a.getValue().compareTo(new Integer(0)) == 0)
                        c.setValue(a.getValue());
                else
                        c.setValue(a.getValue() * b.getValue(), this);
        }

        @Override
        public void updateB() {}
}